var arr = [1, [2,[3]]]

// 1.toString&split&map
/* var arr = arr.toString().split(',').map(item => {
    return Number(item)
});
console.log(arr); */

//2.join&split&map
// var arr = arr.join().split(',').map(item => {
//     return parseInt/* /parseFloat */(item)
// });
// console.log(arr);

//3.递归
/* function digui(e){
    var newArr=[]
    e.forEach(item => {
        if (typeof item=='number') {
            newArr.push(item)
        } else {
            newArr=newArr.concat(digui(item))
        }
    });
    return newArr
}
console.log(digui(arr)); */

//reduce
function reduce(e) {
    return e.reduce((pre, item) => {
        if (typeof item == 'number') {
            pre.push(item)
        } else {
            pre = pre.concat(reduce(item))
        }
        return pre
    }, [])
}
console.log(reduce(arr));